<page-header [autoTitle]="false" *ngIf="!triggerId"></page-header>
<nz-card [nzBordered]="!triggerId">
  <section class="search-section">
    <input nz-input placeholder="备注" [(ngModel)]="keyword" class="search-item"/>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()" class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
    <button nz-button [nzType]="'primary'" (click)="editEntity({})" class="search-add-right"  *ngIf="!triggerId">
      <i class="anticon anticon-plus"></i><span>添加</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th nz-th><span>序号</span></th>
      <th nz-th style="max-width: 150px;"><span>发放对象</span></th>
      <th nz-th><span>金额（￥）</span></th>
      <th nz-th><span>发放次数</span></th>
      <th nz-th *ngIf="!triggerId"><span>已发次数</span></th>
      <th nz-th><span>发放类型</span></th>
      <th nz-th><span>发放日期</span></th>
      <th nz-th><span>发放时间</span></th>
      <th nz-th><span>开始时间</span></th>
      <th nz-th><span>备注</span></th>
      <th nz-th><span>是否开启</span></th>
      <th nz-th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td style="max-width: 150px;">
        <span *ngFor="let cus of data.customerList; let j = index">
          {{cus.name}}<ng-container *ngIf="data.customerList.length > j+1">；</ng-container>
        </span>
      </td>
      <td>{{data.amount}}</td>
      <td>{{data.triggerCount}}</td>
      <td *ngIf="!triggerId">{{data.triggeredCount}}</td>
      <td>{{data.triggerType|dicsNamePipe:triggerType}}</td>
      <td>{{data.triggerType == 2?'周':''}}{{data.triggerType != 3?data.triggerDate:'——'}}{{data.triggerType == 1?'号':''}}</td>
      <td>{{data.triggerTime}}点整</td>
      <td>{{data.beginTime}}</td>
      <td>{{data.remark}}</td>
      <td>{{data.status|yesNoPipe}}</td>
      <td>
        <a href="javascript:void (0);" (click)="editEntity(data)">查看详情</a>
        <ng-container  *ngIf="!triggerId">
          <nz-divider nzType="vertical"></nz-divider>
          <nz-popconfirm [nzTitle]="'确定要'+(data.status == 1?'停用':'启用') +'这个奖金发放器吗？'" (nzOnConfirm)="updateStatus(data)">
            <a nz-popconfirm>{{data.status == 1?'停用':'启用'}}</a>
          </nz-popconfirm>
          <nz-divider nzType="vertical"></nz-divider>
          <a href="javascript:void (0);"  routerLink="/market-trigger/list/detail" [queryParams]="{triggerId: data.id}">查看日志</a>
        </ng-container>
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
